package com.eco.utils;

import org.apache.commons.lang3.StringUtils;

/* loaded from: newfishway-1.0.0-SNAPSHOT.jar:BOOT-INF/classes/com/eco/utils/HexStringUtil.class */
public class HexStringUtil {
    public static String bytesToHexString(byte[] src) {
        StringBuilder stringBuilder = new StringBuilder();
        if (src == null || src.length <= 0) {
            return null;
        }
        for (byte b : src) {
            int v = b & 255;
            String hv = Integer.toHexString(v).toUpperCase();
            if (hv.length() < 2) {
                stringBuilder.append(0);
            }
            stringBuilder.append(hv);
            stringBuilder.append(' ');
        }
        stringBuilder.append("\n");
        return stringBuilder.toString();
    }

    public static byte[] hexString2Bytes(String src) {
        if (src.contains(StringUtils.SPACE)) {
            src = src.replaceAll(StringUtils.SPACE, "");
        }
        int l = src.length() / 2;
        byte[] ret = new byte[l];
        for (int i = 0; i < l; i++) {
            ret[i] = Integer.valueOf(src.substring(i * 2, (i * 2) + 2), 16).byteValue();
        }
        return ret;
    }

    public static String getSensitivityHexString(String str) {
        String str2;
        StringBuffer strBuffer = new StringBuffer();
        strBuffer.append("04 00 00 01 80 01 03 ");
        if (str.toCharArray().length == 3) {
            str2 = "0" + str;
        } else {
            str2 = "00" + str;
        }
        byte[] bytes = hexString2Bytes(str2);
        String dac = bytesToHexString(bytes);
        strBuffer.append(dac.replace("\n", ""));
        strBuffer.append("00 00 00 00");
        return strBuffer.toString();
    }
}